package com.example.controller;

import org.springframework.web.bind.annotation.RestController;

/**
 * 简单学习调用链接elasticsearch
 * @author 夏智峰
 * @create 2018-03-05 9:41
 */
@RestController
public class SpringDateArticleController {
//  @Autowired
//  private ArticleSearchRepository articleSearchRepository;
//
//  @RequestMapping("/add")
//  public void testSaveArticleIndex() {
//    Article article = new Article();
//    article.setId(1L);
//    article.setTitle("springboot integreate elasticsearch");
//    article.setAbstracts("springboot integreate elasticsearch is very easy");
//    article.setContent("elasticsearch based on lucene,"
//            + "spring-data-elastichsearch based on elaticsearch"
//            + ",this tutorial tell you how to integrete springboot with spring-data-elasticsearch");
//    article.setPostTime(new Date());
//    article.setClickCount(1L);
//    articleSearchRepository.save(article);
//  }
//
//  @RequestMapping("del/{id}")
//  public void delById(@PathVariable(value = "id") Long id) {
//    articleSearchRepository.delete(id);
//  }
//  @RequestMapping("/query")
//  public List<Article> testSearch1() {
//    String queryString = "springboot";//搜索关键字
//    QueryStringQueryBuilder builder = new QueryStringQueryBuilder(queryString);
//    Iterable<Article> searchResult = articleSearchRepository.search(builder);
//    Iterator<Article> iterator = searchResult.iterator();
//    List<Article> list = new ArrayList<>();
//    Article article;
//    while (iterator.hasNext()) {
//      article = iterator.next();
//      System.out.println(article);
//      list.add(article);
//    }
//    return list;
//  }
}
